# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=ruby-rss
pkgver=0.2.9
pkgrel=1
pkgdesc='Family of libraries that support various formats of XML "feeds"'
arch=(any)
url='https://github.com/ruby/rss'
license=(BSD)
depends=(ruby-rexml)
makedepends=(ruby-rake ruby-test-unit)
options=(!emptydirs)
source=(https://github.com/ruby/rss/archive/$pkgver/$pkgname-$pkgver.tar.gz)
sha256sums=('255ca347646a0f4aca3d892c778da41cee8b6851b903261bd276d95005493bff')

build() {
  local _gemdir="$(gem env gemdir)"
  cd rss-$pkgver
  gem build rss.gemspec
  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "tmp_install/$_gemdir" \
    --bindir "tmp_install/usr/bin" \
    rss-$pkgver.gem
  find "tmp_install/$_gemdir/gems/" \
    -type f \
    \( \
        -iname "*.o" -o \
        -iname "*.c" -o \
        -iname "*.so" -o \
        -iname "*.time" -o \
        -iname "gem.build_complete" -o \
        -iname "Makefile" \
    \) \
    -delete
  rm -r tmp_install/$_gemdir/cache
}

check() {
  local _gemdir="$(gem env gemdir)"
  cd rss-$pkgver
  GEM_HOME="tmp_install/$_gemdir" rake
}

package() {
  cd rss-$pkgver
  cp -a tmp_install/* "$pkgdir"/
  install -Dm644 LICENSE.txt -t "$pkgdir"/usr/share/licenses/$pkgname/
}
